﻿#include "directory_async_event_args.h"

namespace nsshare
{
namespace sys
{

DirectoryAsyncEventArgs::DirectoryAsyncEventArgs()
    : data_(0), count_(0), error_(0), transfered_(0),
      option_(0)
{
}

DirectoryAsyncEventArgs::DirectoryAsyncEventArgs(Event & e)
    : AsyncEventArgs(e), data_(0), count_(0), error_(0), 
      transfered_(0), option_(0)
{
}

void DirectoryAsyncEventArgs::SetBuffer(void * data, size_t count)
{
    data_ = data;
    count_ = count;
}

void DirectoryAsyncEventArgs::set_option(ReadDirectoryChangesOption::Value option)//NOLINT
{
    option_ = option;
}

void DirectoryAsyncEventArgs::set_completion_delegate(DirectoryAsyncEventHandler * handler)//NOLINT
{
    completion_delegate_ = handler;
}

void * DirectoryAsyncEventArgs::data() const
{
    return data_;
}

size_t DirectoryAsyncEventArgs::count() const
{
    return count_;
}

uint32_t DirectoryAsyncEventArgs::error() const
{
    return error_;
}

uint32_t DirectoryAsyncEventArgs::transfered() const
{
    return transfered_;
}

ReadDirectoryChangesOption::Value DirectoryAsyncEventArgs::option() const
{
    return option_;
}

void DirectoryAsyncEventArgs::OnCompleted(uint32_t error, uint32_t transfered)
{
    error_ = error;
    transfered_ = transfered;
    completion_delegate_(this, *this);
}

}
}